package com.senven.books.modules.system.log.event;

import com.senven.books.modules.system.log.entity.SysLog;
import com.senven.books.modules.system.log.service.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author longshengyi
 * @date 2021/8/13 0013
 **/
@Component
public class SysLogListener {
    @Autowired
    private ISysLogService sysLogService;

    public SysLogListener() {
    }

    @Async
    @Order
    @EventListener({SysLogEvent.class})
    public void saveSysLog(SysLogEvent sysLogEvent) {
        SysLog sysLog = (SysLog)sysLogEvent.getSource();
        this.sysLogService.save(sysLog);
    }
}
